home *** CD-ROM | disk | FTP | other *** search
- /* file sproc1.c */
- #include <sys/types.h>
- #include <unistd.h>
- #include <sys/prctl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <signal.h>
- #define SIZE 3
- int foo1[SIZE];
- volatile int waiting = 1;
-
- void r1(void *val) {
- int i,loc=*(int*)val;
- pid_t pid = getpid();
- while(waiting);
- for(i=0;i<SIZE;i++) foo1[i] = loc;
- for(i=0;i<SIZE;i++) {
- printf("pid %d, foo1[%d] = %d\n",pid,i,foo1[i]);
- }
- }
-
- void main(void) {
- int i;
- int d[SIZE] = {0,1,2};
- for(i=0;i<SIZE;i++) {
- if (-1==sproc(r1,PR_SALL,(void*)&d[i])) {
- printf("sproc failed\n");
- if (kill(0,9)==-1)
- printf("kill failed\n");
- }
- }
- sginap(50);
- waiting = 0;
- sginap(200);
- exit(0);
- }
-